home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17757 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.6 KB

  1. Path: in1.uu.net!demos!usenet
  2. From: Alexey Ruzin <00alex@dbs.demos.su>
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Circular Usage (forward declaration?)
  5. Date: Wed, 17 Apr 1996 16:33:08 +0400
  6. Organization: Demos Online Service
  7. Message-ID: <3174E504.20D9@dbs.demos.su>
  8. References: <MRW.96Apr16184800@tobago.siemens.ch>
  9.         <ltu3ykovzc.fsf@kitz.inferenzsysteme.informatik.th-darmstadt.de>
  10.         <31747631.5970@datalytics.com> <MRW.96Apr17104121@tobago.siemens.ch>
  11. NNTP-Posting-Host: 00alex@dbs.demos.su
  12. Mime-Version: 1.0
  13. Content-Type: text/plain; charset=us-ascii
  14. Content-Transfer-Encoding: 7bit
  15. X-Mailer: Mozilla 2.0 (X11; I; SunOS 5.4 sun4m)
  16.  
  17. Waeckerlin Marc wrote:
  18. > Hi
  19. > Thank you for the answers.
  20. > I know this way, but it does not work in my case, since the members "x"
  21. > absolutely must be no pointers.
  22. > Speaking more exactly, they are pointers, but they are smart pointers.
  23. > In another example, you could get somnething like this, where "CPointer"
  24. > is a smart pointer:
  25. > class CCompany
  26. > {
  27. >   protected:
  28. >     CPointer<CEmployee> m_emp;
  29. >   public:
  30. >     set(CEmployee &p_emp)
  31. >     {
  32. >       m_emp = &p_emp;
  33. >     }
  34. > };
  35. > class CEmployee
  36. > {
  37. >   protected:
  38. >     CPointer<CCompany> m_comp;
  39. >   public:
  40. >     set(CCompany &p_comp)
  41. >     {
  42. >       m_comp = &p_comp;
  43. >     }
  44. > };
  45. > Best Regards
  46. > Marc
  47.  
  48. If you really need to have so hard link between two objects
  49. may be you may bind both objects in one?
  50.  
  51. You can use derived classes to define your new class:
  52.  
  53. class CEmployee_Company: public CEmployee, public CCompany
  54. {
  55. ...
  56. };
  57.  
  58. I don't know what do you really need, it's hard to advice...
  59.